home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.net;
-
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.EOFException;
- import java.io.IOException;
- import java.util.Vector;
- import symjava.sql.SQLException;
-
- public class RemoteObject extends Requester {
- Vector _params;
- String _className;
- ServerList _results;
- NetString _reqStr;
- int _ctorID;
- int _mode;
- int _objectID;
- boolean _disabled = true;
-
- public RemoteObject(String className, int objectID, ClientSession sess) {
- super(sess);
- this._disabled = false;
- this.setObject(className, objectID);
- }
-
- public void setObject(String className, int objectID) {
- this._className = new String(className);
- this._objectID = objectID;
- }
-
- public void disable() {
- this._disabled = true;
- }
-
- protected void readResults(DataInputStream in) throws SQLException, IOException, ErrorException {
- if (this._mode != 2) {
- ServerObject obj = (ServerObject)NetClass.getNextObject(in);
- if (this._mode == 0 && obj.getType() == 51) {
- try {
- this._ctorID = ((NetData)obj).getInt();
- } catch (EOFException var3) {
- throw new IOException("Invalid Server Object returned.");
- }
- } else if (this._mode == 1 && obj.getType() == 54) {
- this._results = (ServerList)obj;
- } else {
- ((Requester)this).onObjectError(obj);
- }
- }
- }
-
- protected void writeRequest(DataOutputStream out) throws IOException {
- this._reqStr.write(out);
-
- for(int i = 0; i < this._params.size(); ++i) {
- ServerObject s = (ServerObject)this._params.elementAt(i);
- s.write(out);
- }
-
- }
-
- public synchronized int invokeConstructor(int ctor_sel, Vector params) throws SQLException {
- if (this._disabled) {
- throw new SQLException("Error: Remote Object closed");
- } else {
- this._mode = 0;
- this._reqStr = new NetString("proxy" + super._reqDelim + "new" + super._reqDelim + this._className + super._reqDelim + ctor_sel);
- this._params = params;
- ((Requester)this).execute();
- return this._ctorID;
- }
- }
-
- public Vector invokeMethod(int mid) throws SQLException {
- return this.invokeMethod(mid, new Vector());
- }
-
- public Vector invokeMethod(int mid, int data) throws SQLException {
- Vector params = new Vector();
- params.addElement(new Param(0, data));
- return this.invokeMethod(mid, params);
- }
-
- public Vector invokeMethod(int mid, String data) throws SQLException {
- Vector params = new Vector();
- params.addElement(new TextParam(0, data));
- return this.invokeMethod(mid, params);
- }
-
- public Vector invokeMethod(int mid, boolean data) throws SQLException {
- Vector params = new Vector();
- params.addElement(new Param(0, data));
- return this.invokeMethod(mid, params);
- }
-
- public synchronized Vector invokeMethod(int mid, Vector params) throws SQLException {
- if (this._disabled) {
- throw new SQLException("Error: Remote Object closed");
- } else {
- this._mode = 1;
- this._reqStr = new NetString("proxy" + super._reqDelim + "invoke" + super._reqDelim + this._objectID + super._reqDelim + mid);
- this._params = params;
- ((Requester)this).execute();
- return this._results.getObjVector();
- }
- }
-
- public synchronized void invokeDestructor(int oid) throws SQLException {
- if (this._disabled) {
- throw new SQLException("Error: Remote Object closed");
- } else {
- this._mode = 2;
- this._reqStr = new NetString("proxy" + super._reqDelim + "delete" + super._reqDelim + oid);
- ((Requester)this).execute();
- }
- }
- }
-